import java.util.Arrays;

public class Test729 {
    public static void main(String[] args) {
//        不规则的二维数组
        int[][]array = new int[2][];
        array[0] =new int[]{1,2};
        array[1] = new int[]{1,2,3,4};

        for(int i =0;i<array.length;i++)
        {
            for (int j =0;j< array[i].length;j++)
            {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
//            1 2
//            1 2 3 4
        }
    }

    public static void main5(String[] args) {
        int[][] array = {{1, 2, 3}, {4, 5, 6}};
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }

        System.out.println("-----------");
        System.out.println(Arrays.deepToString(array));


        for (int[] temp : array) {
            for (int x : temp) {
                System.out.print(x + "  ");
            }
        }
    }


    public static void main4(String[] args) {
        int[][] array = {{1, 2, 3}, {4, 5, 6}};
        int[][] array2 = new int[][]{{1, 2, 3}, {4, 5, 6}};
        int[][] array3 = new int[2][3];

        int[][] array4 = new int[2][];
        //行不能省略
//        int[][]array5 = new int[][6];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 3; j++) {

            }
        }
    }


    public static void main3(String[] args) {
        int[] arr1 = {2, 4, 6, 3};
        int[] copy = Arrays.copyOf(arr1, arr1.length * 2);
        System.out.println(Arrays.toString(copy));

        int[] copy2 = Arrays.copyOfRange(arr1, 0, 3);
        System.out.println(Arrays.toString(copy2));
    }

    //简答的拷贝
    public static void main2(String[] args) {
        int[] arr1 = {2, 4, 6, 3};
        int[] arr2 = new int[arr1.length];
        for (int i = 0; i < arr1.length; i++) {
            arr2[i] = arr1[i];
        }
        System.out.println(Arrays.toString(arr2));
        System.out.println(Arrays.toString(arr1));
    }

    public static void main1(String[] args) {
        int[] arr1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        int[] arr2 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        System.out.println(Arrays.equals(arr1, arr2));

        int[] arr = new int[10];
        Arrays.fill(arr, 9);
        System.out.println(Arrays.toString(arr));
    }
}
